// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
const _ = db.command
// 云函数入口函数
//云函数向数据库添加数据
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const id=event.id
  const num=event.num
  const select=event.select
  return db.collection('shopping-cart')
  .where({
    openid:wxContext.OPENID
  })
  .update({
    data:{
      goods:_.push({id,num,select})
    }
  })
}